package com.niit.az;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
    //数据库名及版本号
    private static final String DB_NAME = "Students.db";
    private static final int    DB_VERSION = 1;
    //数据库表名及字段名
    public static final String TABLE_NAME = "Stu_infos";
    public static final String STUDENT_ID = "stu_id";
    public static final String STUDENT_NAME = "stu_name";
    public static final String STUDENT_PASSWORD = "stu_password";

    private static final String TABLE_CREATE =
            "create table if not exists "+TABLE_NAME + "(" +STUDENT_ID+" integer primary key autoincrement, " +STUDENT_NAME +" text not null," +STUDENT_PASSWORD+ " text not null" + ");";
    public DBHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(TABLE_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//        db.execSQL("drop table if exists"+TABLE_NAME);
//        onCreate(db);
    }
}
